 /*
  * Copyright (c) 2021, 2023, yishun.cn All rights reserved.
  *
  */
 package cn.shun.dto;

 import lombok.Getter;
 import lombok.Setter;

 /**
  * <p>Project: sboot_2023-cn.shun.dto-ResponseDto
  * <p>Powered by yishun On 2023-04-14 17:56:38
  *
  * @author yishun [2465734101@qq.com]
  * @version 1.0
  * @since 17
  */
 public class ResponseDto {
     @Getter
     @Setter
     private Integer code; //0 代表成功,非0代表失败
     @Getter
     @Setter
     private String message;//当code 非0 具体的错误信息
     @Getter
     @Setter
     private Object data;//接口的数据

     public static ResponseDto success(Object data) {
         ResponseDto dto = new ResponseDto();
         dto.setCode(0);
         dto.setData(data);
         return dto;
     }

     public static ResponseDto error(int code, String message) {
         ResponseDto dto = new ResponseDto();
         dto.setCode(code);
         dto.setMessage(message);
         return dto;
     }

 }
